<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="name here">
    <meta name="author" content="name here">	
	
	 <title>Title here</title>
	 
	<link rel="stylesheet" href="css/jquery.mobile.structure-1.3.0.css">
	<link rel="stylesheet" href="themes/BancoDelPeru.css">
	
	<script src="js/jquery-1.9.1.js"></script>
	<script src="js/jquery.mobile-1.3.0.js"></script>
	<script type="text/javascript" src="js/cordova-2.5.0.js" charset="utf-8" ></script>
	<script src="js/configs.js"></script>
	
	
	
	<script type="text/javascript" charset="utf-8">
	
	var accounttype="1";
	
	
		function iniciar() {			
			document.addEventListener("deviceready", dispositivoListo, false);			
		}
		function dispositivoListo() {
				
		}		
		function checkTransfer(){			
			
	 		var x = $("#text-3").val();
			
	 		$("#txtVerifyAmount").val(x);
			document.getElementById("amountInput").reset();
		}
		
		function doTransfer(){
		
			var cust= window.localStorage["customerID"];
	    	
		    var amount = $("#txtVerifyAmount").val();
		    
			console.log("xxxxxxxxxx " + cust);		
			
			console.log("xxxxxxxxxx " + amount);		 
			
			 $.post("http://"+SERVER_IP_ADDRESS+":8080/WebBancoPeru/rest/account/transfer", {customerID: cust , accountType: accounttype, amount: amount}, function(data){	    		
				      	 
		        if ( "true" == data.status ) {
		        	alert("Done  !!!!!");
		        	window.location.assign("success.html")
		        	
		        } else {
		        	alert("Error");
		        } 
		        	
	    	}, "json");
		}
		
		function savetype(type){
			accounttype=type;
					
		}
		
	</script>
	
</head>
<body onload="iniciar()">

	<div data-role="page">
		<div data-role="header" data-position="fixed">		
			<h1>Banco del Per&uacute;</h1>
		</div>
		
		<div data-role="content">	
			Welcome			
			
			
					<form>
						<fieldset data-role="controlgroup" data-type="horizontal">
						
						<input type="radio" name="unique_selection" id="checka" value="off" onclick="savetype('1')" checked="checked">
						<label for="checka">Checking</label>
						
						<input type="radio" name="unique_selection" id="savea" onclick="savetype('2')" value="other">
						<label for="savea">Savings</label>
						</fieldset>
					</form>
			    </div>
			

		
		
		<form id="amountInput">
    	<label for="text-1">Transfer AMOUNT</label>
        
     	<input type="number" data-clear-btn="true" name="text-3" id="text-3" value="">
		</form>
	
	
			<p>Transfer Options</p>
			<a href="mainmenu.html" data-role="button" data-inline="true" data-mini="false" data-shadow="false">Go back to Menu</a>
			
			<a href="#question" data-rel="popup" data-role="button" data-inline="true" data-transition="flow" onclick="checkTransfer()">Transfer</a>
			<div data-role="popup" id="question">

				<p>Is this the correct Amount:</p>
				<input type="text" id="txtVerifyAmount"/>
				
				<a href="#" data-role="button" data-inline="true" onclick="doTransfer();">Yes</a>
				<a href="transfer.html" data-role="button" data-inline="true" data-mini="false" data-shadow="false">No</a>
			</div>
		</div>
		
		<div data-role="footer" data-position="fixed">
			<h1>Banco del Per&uacute; &copy; 2013</h1>
		</div>
	</div>
	
</body>

</html>